package com.ftg.elvis.controller;

import com.ftg.elvis.pojo.Contact;
import com.ftg.elvis.service.AdminContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/contact")
public class AdminContactController {

	@Autowired
	AdminContactService adminContactService;

	@GetMapping("/showAll")
	public Map<String, Object> showAll(int page, int limit){
		List<Contact> list =  adminContactService.showAll(page, limit);
		Map<String, Object> map = new HashMap<>();
		map.put("code", 0);
		map.put("count", adminContactService.getCount());
		map.put("data", list);
		return map;
	}

	@DeleteMapping("/del/{conid}")
	public int delete(@PathVariable String conid){
		return adminContactService.delete(conid);
	}
}
